/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.be;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.cip.esymons.general.be.ConsejoDepartamental;

/**
 *
 * @author ADMINISTRADOR
 */
@Entity
@Table(name = "col_transferencia")
//@NamedQueries({@NamedQuery(name = "Transferencia.findAll", query = "SELECT t FROM Transferencia t"), @NamedQuery(name = "Transferencia.findByTrsCodigo", query = "SELECT t FROM Transferencia t WHERE t.trsCodigo = :trsCodigo"), @NamedQuery(name = "Transferencia.findByTrsfechaTransferencia", query = "SELECT t FROM Transferencia t WHERE t.trsfechaTransferencia = :trsfechaTransferencia"), @NamedQuery(name = "Transferencia.findByTrstipoTransferencia", query = "SELECT t FROM Transferencia t WHERE t.trstipoTransferencia = :trstipoTransferencia"), @NamedQuery(name = "Transferencia.findByTrsconsejoExterno", query = "SELECT t FROM Transferencia t WHERE t.trsconsejoExterno = :trsconsejoExterno"), @NamedQuery(name = "Transferencia.findByTrsdocumentoRef", query = "SELECT t FROM Transferencia t WHERE t.trsdocumentoRef = :trsdocumentoRef")})
public class Transferencia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "trs_codigo")
    private Long trsCodigo;
    @Column(name = "trs_fechaTransferencia")
    @Temporal(TemporalType.DATE)
    private Date trsfechaTransferencia;
    @Basic(optional = false)
    @Column(name = "trs_tipoTransferencia")
    private Boolean trstipoTransferencia;
    @Column(name = "trs_documentoRef")
    private String trsdocumentoRef;
    @Column(name = "trs_dirDocumento")
    private String trsdirDocumento;

    
    @JoinColumn(name = "col_codigo", referencedColumnName = "col_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Colegiado colCodigo;

    @JoinColumn(name = "cde_codigo", referencedColumnName = "cde_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ConsejoDepartamental consejo;


    public Transferencia() {
    }

    public Transferencia(Long trsCodigo) {
        this.trsCodigo = trsCodigo;
    }

    public Transferencia(Long trsCodigo, Boolean trstipoTransferencia) {
        this.trsCodigo = trsCodigo;
        this.trstipoTransferencia = trstipoTransferencia;
    }

    public Long getTrsCodigo() {
        return trsCodigo;
    }

    public void setTrsCodigo(Long trsCodigo) {
        this.trsCodigo = trsCodigo;
    }

    public Date getTrsfechaTransferencia() {
        return trsfechaTransferencia;
    }

    public void setTrsfechaTransferencia(Date trsfechaTransferencia) {
        this.trsfechaTransferencia = trsfechaTransferencia;
    }

    public Boolean getTrstipoTransferencia() {
        return trstipoTransferencia;
    }

    public void setTrstipoTransferencia(Boolean trstipoTransferencia) {
        this.trstipoTransferencia = trstipoTransferencia;
    }

    public ConsejoDepartamental getConsejo() {
        return consejo;
    }

    public void setConsejo(ConsejoDepartamental consejo) {
        this.consejo = consejo;
    }

    

    public String getTrsdocumentoRef() {
        return trsdocumentoRef;
    }

    public void setTrsdocumentoRef(String trsdocumentoRef) {
        this.trsdocumentoRef = trsdocumentoRef;
    }

    public Colegiado getColCodigo() {
        return colCodigo;
    }

    public void setColCodigo(Colegiado colCodigo) {
        this.colCodigo = colCodigo;
    }

    public String getTrsdirDocumento() {
        return trsdirDocumento;
    }

    public void setTrsdirDocumento(String trsdirDocumento) {
        this.trsdirDocumento = trsdirDocumento;
    }

    public String getTipoTransferencia(){

        String tipoTransf="";
        if(trstipoTransferencia==true){
            tipoTransf = "Viene del";
        }else{
            tipoTransf = "Va al";
        }
        return tipoTransf;
    }

    public String getFechaTransferencia(){
        SimpleDateFormat sd =  new SimpleDateFormat("dd/MM/yyyy");
        return sd.format(trsfechaTransferencia);

    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (trsCodigo != null ? trsCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transferencia)) {
            return false;
        }
        Transferencia other = (Transferencia) object;
        if ((this.trsCodigo == null && other.trsCodigo != null) || (this.trsCodigo != null && !this.trsCodigo.equals(other.trsCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.colegiatura.be.Transferencia[trsCodigo=" + trsCodigo + "]";
    }

    @Transient
    private String aplication;

    public String getAplication() {
        return aplication;
    }

    public void setAplication(String aplication) {
        this.aplication = aplication;
    }

    
}
